public class Vector {
    public Double x;
    public Double y;

    public Vector(Double _x, Double _y) {
        this.x = _x;
        this.y = _y;
    }

    public Double magnitude() {
        return Math.sqrt(x * x + y * y);
    }

    public Vector plus(Vector that) {
        Double x = this.x + that.x;
        Double y = this.y + that.y;
        return new Vector(x, y);
    }

    public Vector minus(Vector that) {
        Double x = this.x - that.x;
        Double y = this.y - that.y;
        return new Vector(x, y);
    }

    public Vector scale(Double factor) {
        Double x = this.x * factor;
        Double y = this.y * factor;
        return new Vector(x, y);
    }

    @Override
    public String toString() {
        return "Vector{" +
                "x=" + x +
                ", y=" + y +
                '}';
    }
}